package com.project.XXXX.api;

import java.util.HashMap;

import javax.servlet.http.HttpSession;

import com.project.XXXX.model.tbl_sysuser;

public class SessionContext {
	private static SessionContext instance;
	private HashMap map;
	
	private SessionContext() {
		map=new HashMap();
	}
	
	public static SessionContext getInstance(){
		if (instance == null)
			instance=new SessionContext();
		return instance;
	}
	
	public synchronized void AddSession(HttpSession session){
		if(session != null){
			//if(session.getAttribute("User") != null)
				map.put(session.getId(), session);
		}
	}
	
	public synchronized void DelSession(HttpSession session){
		if(session != null){
			map.remove(session.getId());
		}
	}
	
	public synchronized HttpSession getSession(String sessionId){
		if(sessionId == null)
			return null;
		return (HttpSession)map.get(sessionId);
	}
	

}
